<script lang="ts">
	let foo = "baz";
	let bar = "qux";
	let result = null;

	async function doPost() {
		let url = navigator.userAgent.includes("Windows")
			? "https://customprotocol.localhost/example.html"
			: "customprotocol://localhost/example.html";
		const res = await fetch(url, {
			method: "POST",
			body: JSON.stringify({
				foo,
				bar,
			}),
		});

		const json = await res.json();
		result = JSON.stringify(json);
	}
</script>

<div class="items-center px-5 py-8 mx-auto lg:px-24">
	<div class="flex flex-wrap mb-12 text-left">
		<input bind:value={foo} />
		<input bind:value={bar} />
		<button type="button" on:click={doPost}> Post it. </button>
		<p>Result:</p>
		<pre>
{result}
</pre>
	</div>
</div>
